package com.voc.im.controller.item;

import com.voc.im.bean.ChatEntry;
import com.voc.im.model.*;
import io.datafx.controller.FXMLController;
import io.datafx.controller.flow.FlowException;
import javafx.fxml.FXML;
import javafx.scene.control.Label;

import javax.annotation.PostConstruct;
import javax.inject.Inject;
import java.io.IOException;

@FXMLController("/fxml/main_chat_entry_item.fxml")
public class ItemChatController {

    @FXML
    private Label label_item_name;
    @FXML
    private Label label_item_body;
    @Inject
    private ChatRecordModel chatRecordModel;

    @PostConstruct
    public void init() throws IOException, FlowException {
        ChatEntry chatEntry = chatRecordModel.getEntryListProperty().get(chatRecordModel.getSelectedEntryIndex().get());
        label_item_name.textProperty().bindBidirectional(chatEntry.getUserRoom().nicknameProperty());
        label_item_body.textProperty().bindBidirectional(chatEntry.getChatRecord().bodyProperty());
    }

}
